/**
 * jims
 */
package com.jims.api.v1.controller.emr;

import com.jims.master.common.data.Message;
import com.jims.master.common.data.StringData;
import com.jims.master.common.persistence.Page;
import com.jims.master.common.utils.SecurityUtil;
import com.jims.master.common.utils.StringUtils;
import com.jims.master.common.web.BaseController;
import com.jims.master.modules.emr.entity.EmrBaseItem;
import com.jims.master.modules.emr.entity.EmrIspublic;
import com.jims.master.modules.emr.service.EmrBaseItemService;
import com.jims.master.modules.emr.service.EmrIspublicService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Controller
 * @author WangYQ
 * @version 2018-08-21
 */
@Controller
@RequestMapping(value = "/emrIspublic")
public class EmrIspublicController extends BaseController {

	@Autowired
	private EmrIspublicService emrIspublicService;
	@Autowired
	private EmrBaseItemService emrBaseItemService;


	/**
	 * @Title: saveEmrBaseItem100
	 * @Description: （添加电子病历细项）
	 * @param
	 * @return java.lang.String
	 * @author WangYQ
	 * @date 2018-08-21
	 * @throws
	 */
	@RequestMapping(value = "V100/saveEmrBaseItem",method ={RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public StringData saveEmrBaseItem(EmrBaseItem emrBaseItem, Model model) {
	    StringData data=new StringData();
		int i=emrBaseItemService.save(emrBaseItem);
        if(i>0){
            data.setCode("success");
            data.setData("保存成功");
        }else{
            data.setCode("error");
            data.setData("保存失败");
        }
        return data;
	}

	/**
	 * @Title: saveEmrIspublic
	 * @Description: （添加电子病历权限）
	 * @param
	 * @return java.lang.String
	 * @author WangYQ
	 * @date 2018-08-21
	 * @throws
	 */
	@RequestMapping(value = "V100/saveEmrIspublic",method ={RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public StringData saveEmrIspublic(EmrIspublic emrIspublic, Model model) {
		StringData data=new StringData();
		int i=emrIspublicService.save(emrIspublic);
		if(i>0){
			data.setCode("success");
			data.setData("保存成功");
		}else{
			data.setCode("error");
			data.setData("保存失败");
		}
		return data;
	}
	/**
	 * @Title: findEmrIspublicV100
	 * @Description: （查询电子病历权限）
	 * @param
	 * @return java.lang.String
	 * @author WangYQ
	 * @date 2018-08-21
	 * @throws
	 */
	@RequestMapping(value = "V100/findEmrIspublic",method ={RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public String findEmrIspublic(@RequestParam(required=true)String org) {
		Message msg=new Message();
		List<EmrIspublic> list=emrIspublicService.findEmrIspublic(org);
		msg.setData(list);
		return SecurityUtil.encryptMsgData(msg);
	}
}